package m3f.interact;

import m3f.data.SingleCachedLoader;
import m3f.data.SingleDataSet;
import m3f.retrieval.Rank;
import m3f.retrieval.RankCases;


public class RankingCaseBase {

	public static void run(String args[]){
		if(args.length < 11){
			System.out.println("Parameters:\n" +
					"\t1 Database file\n" +
					"\t2 Queries file\n" +
					"\t3 Database names\n" +
					"\t4 Queries names\n" +
					"\t5 Trec output file\n" +
					"\t6 Similarity Measure\n" +
					"\t[7 Max number of results]\n" +
					"\t[8 Combined Queries file]\n" +
					"\t[9 Combined Cases file]\n" +
					"\t[10 Query Operator]\n" +
					"\t[11 Case Operator]");
			System.exit(0);
		}
		SingleCachedLoader database = new SingleCachedLoader(args[1], true);
		SingleDataSet queries = new SingleDataSet(args[2], database.features(), true);
		String dbNames = args[3];
		String queriesNames = args[4];
		String trecOutputFile = args[5];
		Rank.SimilarityMeasure measure = Rank.SimilarityMeasure.valueOf(args[6]);
		
		RankCases rank = new RankCases(database, queries, dbNames, queriesNames, measure);
		int maxResults = database.matrixRows();

		maxResults = Integer.valueOf(args[7]);
		String combinedQueriesFile = args[8];
		String combinedCasesFile = args[9];
		Rank.Operator query_operator = Rank.Operator.avg;
		query_operator = Rank.Operator.valueOf(args[10]);
		Rank.Operator case_operator = Rank.Operator.max;
		case_operator = Rank.Operator.valueOf(args[11]);
		rank.ranking(combinedQueriesFile, combinedCasesFile, query_operator, case_operator);	
		rank.writeTrecEvalTopFile(trecOutputFile, maxResults);
	}
}
